package leetCode;

import java.util.HashMap;

public class t1 {
    public static void main(String[] args) {
        new SolutionT1().twoSum(new int[]{2,7,11,15},9);
    }
}
class SolutionT1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer>hashMap=new HashMap<>();
        for (int i=0;i< nums.length;i++){
            if (hashMap.containsKey(target-nums[i])){
                return new int[]{i,hashMap.get(target-nums[i])};
            }else {
                hashMap.put(nums[i],i);
            }
        }
        return nums;
    }
}